package com.thread.lesson.threadpool;

/**
 * @Author: Mr.Xi
 * @Description:
 * @Date: Create in 17:23 2021/7/5
 * @Modified By:
 */

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 测试线程池
 */
public class TestPool {
    public static void main(String[] args) {
        //1.创建服务，创建线程池子
        //newFixedThreadPool 参数为线程池大小
        ExecutorService service = Executors.newFixedThreadPool(10);

        //2.执行
        service.execute(new MyThread());
        service.execute(new MyThread());
        service.execute(new MyThread());
        service.execute(new MyThread());

        //3.关闭连接
        service.shutdown();

    }
}

class MyThread implements Runnable{

    @Override
    public void run() {

        System.out.println(Thread.currentThread().getName());

    }
}
